#!/bin/sh /etc/rc.common
# Copyright (C) 2010 OpenWrt.org

START=99

USE_PROCD=1
PROG="/usr/sbin/netcwmpd"

SERVICE_DAEMONIZE=1
SERVICE_WRITE_PID=1

start_service() {
	local enable=`uci -q get netcwmp.@local[0].enable`
	if [ "$enable" == "1" ]; then
		procd_open_instance
		procd_set_param command "$PROG" -f
		procd_set_param respawn "3" "7" "0"
		procd_close_instance
	fi
}

boot() {
	start
}

service_triggers()
{
	procd_add_reload_trigger netcwmp
}
